/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.manager.search;

import br.com.foxline.model.Corrector;
import br.com.foxline.service.CorrectorService;
import br.com.foxline.util.Msg;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author luciano
 */
@ManagedBean
@ViewScoped
public class ManagerSearchCorrector implements Serializable {

    @EJB
    private CorrectorService correctorService;
    public Corrector corrector;
    public List<Corrector> correctors;
    public Corrector removeCorrector;

    @PostConstruct
    public void init() {
        this.corrector = new Corrector();
        this.correctors = new ArrayList<Corrector>();
    }

    public void search() {
        this.correctors = correctorService.findCorrector(corrector);
    }

    public void clear() {
        init();
    }

    public void remove() {
        removeCorrector.setActive(Boolean.FALSE);
        correctorService.update(removeCorrector);
        this.correctors.remove(removeCorrector);
        correctorService.delete(removeCorrector);
        this.removeCorrector = new Corrector();
        Msg.messagemInfo("Corretor removido");
    }

    public Corrector getCorrector() {
        return corrector;
    }

    public void setCorrector(Corrector corrector) {
        this.corrector = corrector;
    }

    public List<Corrector> getCorrectors() {
        return correctors;
    }

    public void setCorrectors(List<Corrector> correctors) {
        this.correctors = correctors;
    }

    public Corrector getRemoveCorrector() {
        return removeCorrector;
    }

    public void setRemoveCorrector(Corrector removeCorrector) {
        this.removeCorrector = removeCorrector;
    }
}
